package com.example.design.patterns.冰河.行为模式.访问者模式;

import com.example.design.patterns.冰河.行为模式.访问者模式.concreteElement.FloatElement;
import com.example.design.patterns.冰河.行为模式.访问者模式.concreteElement.StringElement;
import com.example.design.patterns.冰河.行为模式.访问者模式.concreteVisitor.ConcreteVisitor;
import java.util.ArrayList;
import java.util.List;

public class Test {
    public static void main(String[] args) {
        ConcreteVisitor visitor = new ConcreteVisitor();
        StringElement stringElement = new StringElement("abc");
        stringElement.accept(visitor);
        System.out.println("-----------------------------------");
        FloatElement floatElement = new FloatElement(Float.parseFloat("1.5"));
        floatElement.accept(visitor);
        System.out.println("-----------------------------------");

        List<Object> result = new ArrayList<>();
        result.add(new StringElement("abc"));
        result.add(new StringElement("abc"));
        result.add(new StringElement("abc"));

        result.add(new FloatElement(Float.parseFloat("1.5")));
        result.add(new FloatElement(Float.parseFloat("1.5")));
        result.add(new FloatElement(Float.parseFloat("1.5")));

        visitor.visitCollection(result);
    }
}
